package com.yuwei.property.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.yuwei.base.BaseViewModel
import com.yuwei.http.ApiService
import com.yuwei.http.entity.PropertyEntity
import com.yuwei.http.entity.TenantEntity
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class PropertyViewModel @Inject constructor(
    val apiService: ApiService
) : BaseViewModel(){
    val getPropertySuccess by lazy {
        MutableLiveData<PropertyEntity>()
    }
    val getTenantSuccess by lazy {
        MutableLiveData<TenantEntity>()
    }
    fun getPropertyList(regionId: Int){
        viewModelScope.launch {
            executeNetwork({
                apiService.getPropertyList(regionId)
            },getPropertySuccess::postValue)
        }
    }
    fun getTenantList(){
        viewModelScope.launch {
            executeNetwork({
                apiService.getTenantList()
            },getTenantSuccess::postValue)
        }
    }
}